package struct
{
	public class Queue
	{
		private var mHead:Node = null;
		private var mTail:Node = null;
		private var mCount:int = 0; 
		
		public function Queue()
		{
		}
		
		public function push(o:Object):void{
			var node:Node = new Node(o);
			if (null != mTail) {
				node.pre = mTail;
				mTail.next = node;
			} else {
				mHead = node;
			}
			mTail = node;
			mCount++;
		}
		
		public function shift():Object{
			if (mHead == null) return null;
			var node:Node = mHead;
			mHead = mHead.next;
			mCount--;
			if (mCount == 0) {
				mHead = mTail = null;
			}
			return node.content;
		}
		
		public function get length():int{
			return mCount;
		}
	}
}